package cn.lxh.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;

/**
 * Person人类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(collection = "person") // Person实体类对应mongodb的person表/文档, 会根据类型上的@Document(collection="sys_user")生成集合
public class Person {

    @Id  // 对应mongodb的表的_id, 添加时不设置_id会自动增长
    private String _id;

    // 姓名
    @Field(name = "name", targetType = FieldType.STRING)
    private String name;

    // 年龄
    @Field(name = "age", targetType = FieldType.INT32)
    private Integer age;

    // 爱好
    private String hobby;
}
